package com.evildog.workspace.dependencies.cloud.config;


import com.evildog.workspace.dependencies.cloud.interceptor.FeignHeadWriteInterceptor;
import feign.Feign;
import feign.Logger;
import feign.Retryer;
import feign.querymap.BeanQueryMapEncoder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class FeignConfiguration {

    /**
     * 这里记录所有，根据实际情况选择合适的日志level
     */
    @Bean
    Logger.Level feignLoggerLevel() {
        return Logger.Level.FULL;
    }
 
    /**
     * 替换解析queryMap的类，实现父类中变量的映射
     */
    @Bean
    public Feign.Builder feignBuilder() {
        return Feign.builder()
                .queryMapEncoder(new BeanQueryMapEncoder())
                .retryer(Retryer.NEVER_RETRY);
    }

    @Bean
    public FeignHeadWriteInterceptor feignHeadWriteInterceptor(){
        return new FeignHeadWriteInterceptor();
    }
}